<h1>Moziműsor</h1>

<?php 

	$idok = SQL_query("SELECT DISTINCT to_char(DATUM,'YYYY.mm.dd. (Day)') AS IDOK, to_char(DATUM,'YYYY.mm.dd.') AS DATUM FROM MUSOR WHERE DATUM > sysdate-1 ORDER BY IDOK");
	// Aznapi filmeket fogja kiíratni
	if(isset($_POST['mikor'])){
	    $aktualisfilm = SQL_query("SELECT DISTINCT FILM.FILMID AS FID,FILM.CIM AS CIM FROM MUSOR, FILM WHERE MUSOR.FILMID=FILM.FILMID AND MUSOR.DATUM > to_date('". $_POST['mikor'] ."','YYYY.mm.dd.')-1 AND MUSOR.DATUM <  to_date('". $_POST['mikor'] ."','YYYY.mm.dd.')+1");
		$ext = SQL_query("SELECT to_char(to_date('". $_POST['mikor'] ."','YYYY.mm.dd.'),'YYYY.mm.dd. Day') AS DATUM FROM DUAL");
		$datum = $ext['DATUM'][0] .'i';
	} else {
		$aktualisfilm = SQL_query("SELECT DISTINCT FILM.FILMID AS FID,FILM.CIM AS CIM FROM MUSOR, FILM WHERE MUSOR.FILMID=FILM.FILMID AND MUSOR.DATUM > sysdate-1 AND MUSOR.DATUM < sysdate");
		$datum = "Mai";
	}
?>

<div class="selectormusor">
Melyik napot szeretné megtekinteni?: <form method="post">
<select name="mikor">
<?php 
for($i=0; $i<count($idok['DATUM']); $i++){
	print '<option value="'. $idok['DATUM'][$i] .'">'. $idok['IDOK'][$i] .'</option>';
}
?>
</select>
<input type="submit" value="Megnézem">
</form>
</div>

<p class="plot"><?php print $datum; ?> műsor</p>
<table>
<tr>
<th>Műsor neve</th>
<th>Előadás időpontjai</th>
</tr>
<?php 
	
	for($i=0; $i<count($aktualisfilm['FID']); $i++){
		print '<tr class="';
		if($i%2==0) print 'a1'; else print 'a2';
		print '">';
		if(isset($_POST['mikor'])){
			$idopontok = SQL_query("SELECT to_char(IDO,'HH24:MI') AS IDO FROM MUSOR WHERE MUSOR.DATUM > to_date('". $_POST['mikor'] ."','YYYY.mm.dd.')-1 AND MUSOR.DATUM < to_date('". $_POST['mikor'] ."','YYYY.mm.dd.')+1 AND FILMID=". $aktualisfilm['FID'][$i] ."");
		} else {
			$idopontok = SQL_query("SELECT to_char(IDO,'HH24:MI') AS IDO FROM MUSOR WHERE MUSOR.DATUM > sysdate-1 AND MUSOR.DATUM < sysdate AND FILMID=". $aktualisfilm['FID'][$i] ."");
		}
			
		print '<td>';
		print '<a href="index.php?p=film&f='. $aktualisfilm['FID'][$i] .'">'. $aktualisfilm['CIM'][$i] .'</a>';
		print '</td>';
		print '<td>';
		for($j=0; $j<count($idopontok['IDO']); $j++){
			print $idopontok['IDO'][$j];
			echo "\t\t\t";
		}
		print '</td>';
		print '</tr>';
	}





?>


</table>
